

#ifndef _FH_MSHC_LITE_DLL_H_
#define _FH_MSHC_LITE_DLL_H_


#include <common.h>
#include <clk.h>
#include <dm.h>
#include <malloc.h>
#include <sdhci.h>

#include <asm/arch/hardware.h>
#include <mmc.h> 


#define PARSE_TX_DL_REC 0
#define PARSE_RX_DL_REC 1
struct rec_dl_info {
	int tx_dl;
	int rx_dl;	
	char *result;
	int pass_times;
	int fail_times;
};
#define INIT_TEST_DATA	(0xdeadbeef)
#define STATE_REC_DATA_HI	0
#define STATE_REC_DATA_LO	1


enum{
AUTO_SCAN_HS = 0,
AUTO_SCAN_HS200,
AUTO_SCAN_HS400,
AUTO_SCAN_END,
};

#define TX_DATA_OFFSET_WITH_CMD 8


int mshc_auto_get_mmc_cid(struct sdhci_host *host, u32 *ret_cid, u8 *emmc_name);
int mshc_auto_write_emmc_tuning_data(struct sdhci_host *host, u8 *buf);
int mshc_auto_get_mmc_ext(struct sdhci_host *host, u8 *ext_reg);
int mshc_auto_get_emmc_tuning_data(struct sdhci_host *host, u8 *buf);
int mshc_auto_hs400_es_fix_test(struct sdhci_host *host, u32 init_tx_val,
u32 init_rx_cmd_val, u32 init_rx_val, u32 test_times);
int mshc_auto_hs400_es_txdata_dl_rec(struct sdhci_host *host, struct rec_dl_info *p_info, int rec_dl_size,
u32 init_rx_cmd_val, u32 init_rx_data_val, u32 step_size);
int mshc_auto_hs400_es_rxdata_dl_rec(struct sdhci_host *host, struct rec_dl_info *p_info, int rec_dl_size,
u32 init_rx_cmd_val, u32 init_tx_val, u32 step_size);
int mshc_auto_hs400_es_rxcmd_dl_rec(struct sdhci_host *host, struct rec_dl_info *p_info, int rec_dl_size,
u32 init_tx_val, u32 step_size, u32 *ret_cid);
int mshc_auto_hs400_classic_rxdata_dl_rec(struct sdhci_host *host, struct rec_dl_info *p_info, int rec_dl_size,
u32 init_rx_cmd_val, u32 init_tx_val, u32 step_size);
int mshc_auto_hs400_classic_fix_test(struct sdhci_host *host, u32 init_tx_val,
u32 init_rx_cmd_val, u32 init_rx_val, u32 test_times);
int mshc_auto_hs400_classic_rxcmd_dl_rec(struct sdhci_host *host, struct rec_dl_info *p_info, int rec_dl_size,
u32 init_tx_val, u32 step_size, u32 *ret_cid);
int mshc_auto_hs400_classic_txdata_dl_rec(struct sdhci_host *host, struct rec_dl_info *p_info, int rec_dl_size,
u32 init_rx_cmd_val, u32 init_rx_data_val, u32 step_size);
int mshc_hs200_auto_fix_test(struct sdhci_host *host, u32 init_tx_val,
u32 init_rx_cmd_val, u32 init_rx_val, u32 test_times, u32 tuning_mode);
int mshc_auto_rxdata_dl_rec(struct sdhci_host *host, struct rec_dl_info *p_info, int rec_dl_size,
u32 init_rx_cmd_val, u32 init_tx_val, u32 step_size, u32 tuning_mode);
int mshc_auto_rxcmd_dl_rec(struct sdhci_host *host, struct rec_dl_info *p_info, int rec_dl_size,
u32 init_tx_val, u32 step_size, u32 emmc_init, u32 *ret_cid, u32 tuning_mode);
int emmc_parse_dl_rec(struct rec_dl_info *p_info, int rec_dl_size, u32 *p_ret_dl, int tx_or_rx, u32 *p_ret_win_len);
int mshc_auto_txcmd_dl_rec(struct sdhci_host *host, struct rec_dl_info *p_info, int rec_dl_size,
u32 init_rx_cmd_val, u32 step_size, u32 emmc_init, u32 *cmp_cid, u32 tuning_mode);
#endif
